|
Groovy JDK |
Method Summary | |
---|---|
boolean
|
asBoolean()
Coerce an Object array to a boolean value. |
Object
|
asType(Class clazz)
Converts the given array to either a List, Set, or SortedSet. |
Number
|
count(Object value)
Counts the number of occurrences of the given value inside this array. |
boolean
|
equals(List right)
Determines if the contents of this array are equal to the contents of the given list, in the same order. |
Collection
|
flatten()
Flatten an array. |
List
|
getAt(Collection indices)
Select a List of items from an Object array using a Collection to identify the indices to be selected. |
List
|
getAt(Range range)
Support the range subscript operator for an Array |
List
|
getAt(IntRange range)
|
List
|
getAt(EmptyRange range)
|
List
|
getAt(ObjectRange range)
|
Object
|
inject(Object initialValue, Closure closure)
Iterates through the given array of objects, passing in the initial value to the closure along with the current iterated item then passing into the next iteration the value of the previous closure. |
Iterator
|
iterator()
Attempts to create an Iterator for the given object by first converting it to a Collection. |
String
|
join(String separator)
Concatenates the toString() representation of each
items in this array, with the given String as a separator between each
item.
|
Object
|
max()
Adds max() method to Object arrays. |
Object
|
max(Closure closure)
Selects the maximum value found from the Object array using the closure to determine the correct ordering. |
Object
|
max(Comparator comparator)
Selects the maximum value found from the Object array using the given comparator. |
Object
|
min()
Adds min() method to Object arrays. |
Object
|
min(Comparator comparator)
Selects the minimum value found from the Object array using the given comparator. |
Object
|
min(Closure closure)
Selects the minimum value found from the Object array using the closure to determine the correct ordering. |
Object[]
|
minus(Collection removeMe)
Create an array composed of the elements of the first array minus the elements of the given collection. |
Object[]
|
minus(Object[] removeMe)
Create an array composed of the elements of the first array minus the elements of the given array. |
Object[]
|
minus(Object operand)
Create a new object array composed of the elements of the first array minus the operand. |
Object[]
|
reverse()
Reverse the items in an Object array. |
Object[]
|
reverseEach(Closure closure)
Iterate over each element of the array in the reverse order. |
int
|
size()
Provide the standard Groovy size() method for an array.
|
Object[]
|
sort()
Sorts the given Object array into sorted order. |
Object[]
|
sort(Comparator comparator)
Sorts the given Object array into sorted order using the given comparator. |
Object[]
|
sort(Closure closure)
Sorts the given Object array into a newly created array using the Closure to determine the correct ordering. |
Object
|
sum()
Sums the items in an array. |
Object
|
sum(Object initialValue)
Sums the items in an array, adding the result to some initial value. |
Object
|
sum(Closure closure)
Sums the result of apply a closure to each item of an array. |
Object
|
sum(Object initialValue, Closure closure)
Sums the result of applying a closure to each item of an array to some initial value. |
String
|
toArrayString()
Returns the string representation of the given array. |
List
|
toList()
Allows conversion of arrays into a mutable List. |
SpreadMap
|
toSpreadMap()
Creates a spreadable map from this array. |
String
|
toString()
Returns the string representation of this array's contents. |
Method Detail |
---|
public boolean asBoolean()
public Object asType(Class clazz)
clazz
- the desired class.public Number count(Object value)
compareTo(value) == 0
or equals(value)
).value
- the value being searched for.public boolean equals(List right)
false
if either collection is null
.right
- the list being compared.public Collection flatten()
public List getAt(Collection indices)
indices
- a Collection of indices.public List getAt(Range range)
range
- a Range.public List getAt(IntRange range)
range
- an IntRange.public List getAt(EmptyRange range)
range
- an EmptyRange.public List getAt(ObjectRange range)
range
- an ObjectRange.public Object inject(Object initialValue, Closure closure)
initialValue
- an initialValue.closure
- a closure.public Iterator iterator()
public String join(String separator)
toString()
representation of each
items in this array, with the given String as a separator between each
item.separator
- a String separator.public Object max()
public Object max(Closure closure)
closure
- a Closure used to determine the correct ordering.public Object max(Comparator comparator)
comparator
- a Comparator.public Object min()
public Object min(Comparator comparator)
comparator
- a Comparator.public Object min(Closure closure)
closure
- a Closure used to determine the correct ordering.public Object[] minus(Collection removeMe)
removeMe
- a Collection of elements to remove.public Object[] minus(Object[] removeMe)
removeMe
- an array of elements to remove.public Object[] minus(Object operand)
operand
- an element to remove from the array.public Object[] reverse()
public Object[] reverseEach(Closure closure)
closure
- a closure to which each item is passed.public int size()
size()
method for an array.public Object[] sort()
public Object[] sort(Comparator comparator)
comparator
- a Comparator used for the comparison.public Object[] sort(Closure closure)
closure
- a Closure used to determine the correct ordering.public Object sum()
public Object sum(Object initialValue)
initialValue
- the items in the array will be summed to this initial value.public Object sum(Closure closure)
array.sum(closure)
is equivalent to:
array.collect(closure).sum()
.closure
- a single parameter closure that returns a numeric value..public Object sum(Object initialValue, Closure closure)
array.sum(initVal, closure)
is equivalent to:
array.collect(closure).sum(initVal)
.closure
- a single parameter closure that returns a numeric value..initialValue
- the closure results will be summed to this initial value.public String toArrayString()
{1, 2, "a"}
.public List toList()
public SpreadMap toSpreadMap()
public String toString()
|
Groovy JDK |